#ifndef __UC1701_H
#define __UC1701_H

#include "stm32f10x.h"
#include "infusion.h"
#include "BAT_Cal.h"

#define H                   1
#define L                   0

#define UC1701_RSTB_PORT    GPIOA
#define UC1701_RSTB_PIN     GPIO_Pin_6

#define UC1701_SDI_PORT     GPIOC
#define UC1701_SDI_PIN      GPIO_Pin_5

#define UC1701_SCL_PORT     GPIOC
#define UC1701_SCL_PIN      GPIO_Pin_4

#define UC1701_CS_PORT      GPIOA
#define UC1701_CS_PIN       GPIO_Pin_5

#define UC1701_RS_PORT      GPIOA
#define UC1701_RS_PIN       GPIO_Pin_7

#define LCD_BL_PORT      	GPIOB
#define LCD_BL_PIN       	GPIO_Pin_12

#define UC1701_RSTB(x)      (x !=0)?GPIO_SetBits(UC1701_RSTB_PORT, UC1701_RSTB_PIN) :GPIO_ResetBits(UC1701_RSTB_PORT, UC1701_RSTB_PIN)
#define UC1701_SDI(x)       (x !=0)?GPIO_SetBits(UC1701_SDI_PORT,  UC1701_SDI_PIN)  :GPIO_ResetBits(UC1701_SDI_PORT,  UC1701_SDI_PIN)
#define UC1701_SCL(x)       (x !=0)?GPIO_SetBits(UC1701_SCL_PORT,  UC1701_SCL_PIN)  :GPIO_ResetBits(UC1701_SCL_PORT,  UC1701_SCL_PIN)
#define UC1701_CS(x)        (x !=0)?GPIO_SetBits(UC1701_CS_PORT,   UC1701_CS_PIN)   :GPIO_ResetBits(UC1701_CS_PORT,   UC1701_CS_PIN)
#define UC1701_RS(x)        (x !=0)?GPIO_SetBits(UC1701_RS_PORT,   UC1701_RS_PIN)   :GPIO_ResetBits(UC1701_RS_PORT,   UC1701_RS_PIN)
#define LCD_BL(x)        	(x !=0)?GPIO_SetBits(LCD_BL_PORT,      LCD_BL_PIN)      :GPIO_ResetBits(LCD_BL_PORT,      LCD_BL_PIN)

void Write_uc1701_COM(u8 COMDADA_4SPI);
void Write_uc1701_DISPLAY_DATA_serial_4SPI(u8 DADA_4SPI);
void Delay_1ms(unsigned long value);
void HDReset(void);
void refreshContent(void);
void ScreenInital(void);
void clearScreen(void);
void clearContent(void);
void updateScreen(void);
void insertGet(void);
void updateGet(void);
void analyzeNET(void);
void updatePost(void);
void displayNotice(uint8_t block,uint8_t colStart,unsigned char *s, uint8_t length);
void display8x8(uint8_t page, uint8_t colStart, unsigned char *s, uint8_t length);
void display16x16(uint8_t block,uint8_t colStart,unsigned char *s, uint8_t length);
uint8_t insertPost(void);
void initFire(void);
void writeLine(uint8_t height);
void writeFill(uint8_t height);

#endif
